package com.boot.security.server.dao.record;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.record.TswCouponTakeRecord;

@Mapper
public interface TswCouponTakeRecordDao {

    @Select("select * from tsw_coupon_take_record t where t.id = #{id}")
    TswCouponTakeRecord getById(Long id);

    @Delete("delete from tsw_coupon_take_record where id = #{id}")
    int delete(Long id);

    int update(TswCouponTakeRecord tswCouponTakeRecord);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_coupon_take_record(user_id, coupon_id, draw_time, pickup_source, getRecord_note, getRecord_remark) values(#{userId}, #{couponId}, #{drawTime}, #{pickupSource}, #{getRecordNote}, #{getRecordRemark})")
    int save(TswCouponTakeRecord tswCouponTakeRecord);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswCouponTakeRecord> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
